package com.pt.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.time.LocalDateTime;

@Data
@TableName("invitation")
public class Invitation {
    @TableId(type = IdType.AUTO)
    private Long id;
    
    private String code;
    
    private Long creatorId;
    
    private Long usedBy;
    
    private Integer status;
    
    private LocalDateTime createdTime;
    
    private LocalDateTime usedTime;
    
    private LocalDateTime expireTime;
    
    // 注意：这里使用不同的字段名以避免与数据库字段冲突
    public Long getUserId() {
        return creatorId;
    }
    
    public void setUserId(Long userId) {
        this.creatorId = userId;
    }
    
    // 状态常量
    public static final int STATUS_AVAILABLE = 0;  // 可用
    public static final int STATUS_USED = 1;       // 已使用
    public static final int STATUS_DISABLED = 2;   // 禁用
    
    /**
     * 获取状态描述
     */
    public String getStatusDesc() {
        switch (status) {
            case STATUS_AVAILABLE:
                return "可用";
            case STATUS_USED:
                return "已使用";
            case STATUS_DISABLED:
                return "禁用";
            default:
                return "未知";
        }
    }
    
    /**
     * 检查是否已过期
     */
    public boolean isExpired() {
        return expireTime != null && LocalDateTime.now().isAfter(expireTime);
    }
} 